<?php

namespace backend\models;

use Yii;
use common\models\UserInfo;

/**
 * This is the model class for table "pay_trade_rebate".
 *
 * @property integer $uid
 * @property string $trade_no
 * @property string $money
 * @property string $rebate_money
 * @property integer $level
 * @property integer $rebate_uid
 * @property string $rebate_rate
 * @property integer $state
 * @property integer $create_time
 * @property string $memo
 */
class PayTradeRebate extends \yii\db\ActiveRecord
{
    public function attributes()
    {
        // add related fields to searchable attributes
        return array_merge(parent::attributes(), ['tel','show_money','take_time','apply_time']);
    }
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'pay_trade_rebate';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'trade_no'], 'required'],
            [['uid', 'level', 'rebate_uid', 'state', 'create_time'], 'integer'],
            [['money', 'rebate_money', 'rebate_rate'], 'number'],
            [['memo'], 'string'],
            [['trade_no'], 'string', 'max' => 64]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'uid' => '用户ID',
            'trade_no' => '订单号',
            'money' => '订单总金额',
            'rebate_money' => '返点金额',
            'level' => 'Level',
            'rebate_uid' => 'Rebate Uid',
            'rebate_rate' => 'Rebate Rate',
            'state' => 'State',
            'create_time' => 'Create Time',
            'memo' => '备注',
            'tel' => '电话号码',
            'show_money'=> '金额',
            'take_time' => '时间'
        ];
    }
    
    public function getTel0() {
        return $this->hasOne(UserInfo::className(), ['id'=>'uid']);
    }
}
